#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import opengate as gate
from opengate.contrib.phantoms import nemaiec


def add_177lu_sphere_sources(sim, activity):
    # units
    keV = gate.g4_units.keV

    # Lu177 source (only the gammas) in all spheres
    spheres = [10, 13, 17, 22, 28, 37]
    ac = activity / sim.user_info.number_of_threads
    activity_Bq_mL = [ac] * 6
    sources = nemaiec.add_spheres_sources(
        sim, "iec", "sources", spheres, activity_Bq_mL, verbose=True
    )
    for source in sources:
        source.particle = "gamma"
        source.energy.type = "spectrum_discrete"
        source.energy.spectrum_weights = [
            0.001726,
            0.0620,
            0.000470,
            0.1038,
            0.002012,
            0.00216,
        ]
        source.energy.spectrum_energies = [
            071.6418 * keV,
            112.9498 * keV,  # 6.2 %
            136.7245 * keV,
            208.3662 * keV,  # 10.38 %
            249.6742 * keV,
            321.3159 * keV,
        ]

    return sources
